package com.coc.action;

import com.coc.bean.*;
import com.coc.bean.res.*;
import com.coc.bean.war.Camp;
import com.coc.bean.war.Tran;
import com.coc.bean.def.*;
import com.coc.dao.BuildSettingXML;
import com.coc.dao.Building;
import com.coc.dao.EloUserDAO;
import com.coc.dao.MemCachedDAO;
import com.coc.service.CocBattleService;
import com.coc.service.CocMapService;
import com.coc.service.CocUserService;
import com.coc.util.MemCacheUtil;
import com.coc.util.PubFun;
import com.coc.util.SignException;

import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Random;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.actions.DispatchAction;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class OldDataAction extends BaseAction {
	/*
	public ActionForward del(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		try {
			for (int i = 1; i < 100; i++) {
				MemCacheUtil.delValue("cm_" + i);
			}

			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	public ActionForward reg(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		try {
			String openid = request.getParameter("openid");
			String name = request.getParameter("name");
			CcEloUser ceu = getEloUserDAO().findBySNSName(name);
			// "map":{"T1":["6,6","14,21","4,36","31,20"],"T2":["5,25","8,22","20,8"],
			// "T3":["13,4","25,37"],"T4":["5,3","3,8","4,12","14,28","14,36","22,31","35,25"]
			// ,"T5":["24,34","26,34","25,29","19,3"],
			// "T6":["7,9","4,16","4,28","19,35","31,27","36,17","33,12","28,3"],
			// "T7":["12,8","33,32"],"T8":["30,9","23,29","22,33","23,36"]
			// ,"T9":["28,33","3,32","9,31","4,20","34,20","25,9"],"T10":["23,6","9,16","27,28"]
			// ,"T11":["8,3","13,17","12,30","6,34","27,30","34,4"]
			// ,"SLAV":["24,25"],"HALL":"23,20,1,0","BARK":["20,22,1,0"],"CAMP":["17,11,1,0"],"GOLS":["16,19,1,0"],"ELXS":["20,18,1,0"],"GOLM":["24,13,1,0"],"ELXM":["28,17,1,0"]}

			if (ceu == null) {
				ceu = new CcEloUser();
				ceu.setSnsid(openid);
				ceu.setHtlv(2);
				ceu.setName(name);
				getEloUserDAO().saveOrUpdate(ceu);
				CcMap cm = new CcMap();
				cm.setUid(Integer.valueOf(ceu.getId()));
				CcUser cu = new CcUser();
				cu.setQqp(227);
				cu.setHtlv(2);
				cu.setId(Integer.valueOf(ceu.getId()));
				cu.setSnsname(name);
				cu.setSnsid(openid);
				cu.setGold(Integer.valueOf(500));
				cu.setElixir(Integer.valueOf(500));
				cu.setGem(Integer.valueOf(500));
				cm.setCcuser(cu);
				cm.initMap();
				// 添加一个2本基地,1个工人,一个cann,一个golm,elxm,gols,elxs,bark,camp
				Hall tmp = new Hall();
				tmp.setBegtime(0);
				tmp.setLv(2);
				tmp.setX(23);
				tmp.setY(20);
				cm.setHall(tmp);
				cm.setMap(SetMap(cm.getMap(), 23, 20, 4));
				cm.setTotalUnitSize(cm.getTotalUnitSize() + 4 * 4);
				Slav slav = new Slav();
				slav.setX(24);
				slav.setY(25);
				List list = new ArrayList();
				list.add(slav);
				cm.setSlavs(list);
				cm.setMap(SetMap(cm.getMap(), 24, 25, 2));
				cm.setTotalUnitSize(cm.getTotalUnitSize() + 2 * 2);
				Cann cann = new Cann();
				cann.setX(23);
				cann.setY(16);
				list = new ArrayList();
				list.add(cann);
				cm.setCanns(list);
				cm.setMap(SetMap(cm.getMap(), 23, 16, 3));
				cm.setTotalUnitSize(cm.getTotalUnitSize() + 3 * 3);
				Golm golm = new Golm();
				golm.setLv(1);
				golm.setLefttime(System.currentTimeMillis());
				golm.setX(24);
				golm.setY(13);
				list = new ArrayList();
				list.add(golm);
				cm.setGolms(list);
				cm.setMap(SetMap(cm.getMap(), 24, 13, 3));
				cm.setTotalUnitSize(cm.getTotalUnitSize() + 3 * 3);
				Elxm elxm = new Elxm();
				elxm.setLv(1);
				elxm.setLefttime(System.currentTimeMillis());
				elxm.setX(28);
				elxm.setY(17);
				list = new ArrayList();
				list.add(elxm);
				cm.setElxms(list);
				cm.setMap(SetMap(cm.getMap(), 28, 17, 3));
				cm.setTotalUnitSize(cm.getTotalUnitSize() + 3 * 3);
				Elxs elxs = new Elxs();
				elxs.setLv(1);
				elxs.setX(20);
				elxs.setY(18);
				list = new ArrayList();
				list.add(elxs);
				cm.setElxss(list);
				cm.setMap(SetMap(cm.getMap(), 20, 18, 3));

				Gols gols = new Gols();
				gols.setLv(1);
				gols.setX(16);
				gols.setY(19);
				list = new ArrayList();
				list.add(gols);
				cm.setGolss(list);
				cm.setMap(SetMap(cm.getMap(), 16, 19, 3));
				cm.setTotalUnitSize(cm.getTotalUnitSize() + 3 * 3);
				Tran bark = new Tran();
				bark.setX(20);
				bark.setY(22);
				bark.setLv(1);
				list = new ArrayList();
				list.add(bark);
				cm.setBarks(list);
				cm.setMap(SetMap(cm.getMap(), 20, 22, 3));
				cm.setTotalUnitSize(cm.getTotalUnitSize() + 3 * 3);
				Camp camp = new Camp();
				camp.setX(17);
				camp.setY(11);
				camp.setLv(1);
				list = new ArrayList();
				list.add(camp);
				cm.setCamps(list);
				cm.setMap(SetMap(cm.getMap(), 30, 30, 3));
				cm.setTotalUnitSize(cm.getTotalUnitSize() + 3 * 3);
				// T6,7,11 size=3
				// T1":["6,6","14,21","4,36","31,20"],
				Hashtable<String, List<Tree>> trees = new Hashtable<String, List<Tree>>();

				List<Tree> treeList = new ArrayList<Tree>();
				Tree tree = new Tree();
				tree.setX(6);
				tree.setY(6);
				cm.setMap(SetMap(cm.getMap(), 6, 6, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(14);
				tree.setY(21);
				cm.setMap(SetMap(cm.getMap(), 14, 21, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(4);
				tree.setY(36);
				cm.setMap(SetMap(cm.getMap(), 4, 36, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(31);
				tree.setY(20);
				cm.setMap(SetMap(cm.getMap(), 31, 20, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				trees.put("T1", treeList);
				// T2":["5,25","8,22","20,8"],
				treeList = new ArrayList<Tree>();
				tree = new Tree();
				tree.setX(5);
				tree.setY(25);
				cm.setMap(SetMap(cm.getMap(), 5, 25, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(8);
				tree.setY(22);
				cm.setMap(SetMap(cm.getMap(), 8, 22, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(20);
				tree.setY(8);
				cm.setMap(SetMap(cm.getMap(), 20, 8, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				trees.put("T2", treeList);
				// T3"::["13,4","25,37"]
				treeList = new ArrayList<Tree>();
				tree = new Tree();
				tree.setX(13);
				tree.setY(4);
				cm.setMap(SetMap(cm.getMap(), 13, 4, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(25);
				tree.setY(37);
				cm.setMap(SetMap(cm.getMap(), 25, 37, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				trees.put("T3", treeList);
				// T4":":["5,3","3,8","4,12","14,28","14,36","22,31","35,25"],
				treeList = new ArrayList<Tree>();
				tree = new Tree();
				tree.setX(5);
				tree.setY(3);
				cm.setMap(SetMap(cm.getMap(), 5, 3, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(3);
				tree.setY(8);
				cm.setMap(SetMap(cm.getMap(), 3, 8, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(4);
				tree.setY(12);
				cm.setMap(SetMap(cm.getMap(), 4, 12, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				// ==
				tree = new Tree();
				tree.setX(14);
				tree.setY(28);
				cm.setMap(SetMap(cm.getMap(), 14, 28, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(14);
				tree.setY(36);
				cm.setMap(SetMap(cm.getMap(), 14, 36, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(22);
				tree.setY(31);
				cm.setMap(SetMap(cm.getMap(), 22, 31, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(35);
				tree.setY(25);
				cm.setMap(SetMap(cm.getMap(), 35, 25, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				trees.put("T4", treeList);
				// T5":["24,34","26,34","25,29","19,3"]
				treeList = new ArrayList<Tree>();
				tree = new Tree();
				tree.setX(24);
				tree.setY(34);
				cm.setMap(SetMap(cm.getMap(), 24, 34, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(26);
				tree.setY(34);
				cm.setMap(SetMap(cm.getMap(), 26, 34, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(25);
				tree.setY(29);
				cm.setMap(SetMap(cm.getMap(), 25, 29, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(19);
				tree.setY(3);
				cm.setMap(SetMap(cm.getMap(), 19, 3, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				trees.put("T5", treeList);
				// "T6":["7,9","4,16","4,28","19,35","31,27","36,17","33,12","28,3"],
				treeList = new ArrayList<Tree>();
				tree = new Tree();
				tree.setX(7);
				tree.setY(9);
				cm.setMap(SetMap(cm.getMap(), 7, 9, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(4);
				tree.setY(16);
				cm.setMap(SetMap(cm.getMap(), 4, 16, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(4);
				tree.setY(28);
				cm.setMap(SetMap(cm.getMap(), 4, 28, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(19);
				tree.setY(35);
				cm.setMap(SetMap(cm.getMap(), 19, 35, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(31);
				tree.setY(27);
				cm.setMap(SetMap(cm.getMap(), 31, 27, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(36);
				tree.setY(17);
				cm.setMap(SetMap(cm.getMap(), 36, 17, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(33);
				tree.setY(12);
				cm.setMap(SetMap(cm.getMap(), 33, 12, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(28);
				tree.setY(3);
				cm.setMap(SetMap(cm.getMap(), 28, 3, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				trees.put("T6", treeList);
				// T7":["12,8","33,32"]
				treeList = new ArrayList<Tree>();
				tree = new Tree();
				tree.setX(12);
				tree.setY(8);
				cm.setMap(SetMap(cm.getMap(), 12, 8, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(33);
				tree.setY(32);
				cm.setMap(SetMap(cm.getMap(), 33, 32, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				trees.put("T7", treeList);
				// "T8":["30,9","23,29","22,33","23,36"],
				treeList = new ArrayList<Tree>();
				tree = new Tree();
				tree.setX(30);
				tree.setY(9);
				cm.setMap(SetMap(cm.getMap(), 30, 9, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(23);
				tree.setY(29);
				cm.setMap(SetMap(cm.getMap(), 23, 29, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(22);
				tree.setY(33);
				cm.setMap(SetMap(cm.getMap(), 22, 33, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(23);
				tree.setY(36);
				cm.setMap(SetMap(cm.getMap(), 23, 36, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				trees.put("T8", treeList);
				// "T9":["28,33","3,32","9,31","4,20","34,20","25,9"]
				treeList = new ArrayList<Tree>();
				tree = new Tree();
				tree.setX(28);
				tree.setY(33);
				cm.setMap(SetMap(cm.getMap(), 28, 33, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(3);
				tree.setY(32);
				cm.setMap(SetMap(cm.getMap(), 3, 32, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(9);
				tree.setY(31);
				cm.setMap(SetMap(cm.getMap(), 9, 31, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(4);
				tree.setY(20);
				cm.setMap(SetMap(cm.getMap(), 4, 20, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(34);
				tree.setY(20);
				cm.setMap(SetMap(cm.getMap(), 34, 20, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(25);
				tree.setY(9);
				cm.setMap(SetMap(cm.getMap(), 25, 9, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				trees.put("T9", treeList);
				// "T10":["23,6","9,16","27,28"]
				treeList = new ArrayList<Tree>();
				tree = new Tree();
				tree.setX(23);
				tree.setY(6);
				cm.setMap(SetMap(cm.getMap(), 23, 6, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(9);
				tree.setY(16);
				cm.setMap(SetMap(cm.getMap(), 9, 16, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(27);
				tree.setY(28);
				cm.setMap(SetMap(cm.getMap(), 27, 28, 2));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 2 * 2);
				treeList.add(tree);
				trees.put("T10", treeList);
				// "T11":["8,3","13,17","12,30","6,34","27,30","34,4"]
				treeList = new ArrayList<Tree>();
				tree = new Tree();
				tree.setX(8);
				tree.setY(3);
				cm.setMap(SetMap(cm.getMap(), 8, 3, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(13);
				tree.setY(17);
				cm.setMap(SetMap(cm.getMap(), 13, 17, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(12);
				tree.setY(30);
				cm.setMap(SetMap(cm.getMap(), 12, 30, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(6);
				tree.setY(34);
				cm.setMap(SetMap(cm.getMap(), 6, 34, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(27);
				tree.setY(30);
				cm.setMap(SetMap(cm.getMap(), 27, 30, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				tree = new Tree();
				tree.setX(34);
				tree.setY(4);
				cm.setMap(SetMap(cm.getMap(), 34, 4, 3));
				cm.setTotalTreeSize(cm.getTotalUnitSize() + 3 * 3);
				treeList.add(tree);
				trees.put("T11", treeList);
				cm.setTrees(trees);
				MemCacheUtil.addObject("cm_" + cm.getUid(), cm);
				out.print("{\"sign\":{\"value\":" + cm.getUid() + "}}");
			} else {
				out.print("{\"sign\":{\"value\":0}}");
			}

			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	public ActionForward rereg(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		try {
			String uid = request.getParameter("uid");
			CcEloUser ceu = getEloUserDAO().findByID(Integer.parseInt(uid));
			getEloUserDAO().saveOrUpdate(ceu);
			CcMap cm = new CcMap();
			cm.setUid(Integer.valueOf(ceu.getId()));
			CcUser cu = new CcUser();
			cu.setId(Integer.valueOf(ceu.getId()));
			cu.setGold(Integer.valueOf(50000));
			cu.setElixir(Integer.valueOf(50000));
			cu.setGem(Integer.valueOf(2005));
			cm.setCcuser(cu);
			MemCacheUtil.setObject("cm_" + cm.getUid(), cm);
			cm = (CcMap) MemCacheUtil.getObject("cm_" + cm.getUid());
			out.print("{" + cm.toString() + "}");
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	public ActionForward gmlogin(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		try {
			// String uid = request.getParameter("uid");
			String openid = request.getParameter("openid");
			String pass = request.getParameter("password");
			// CcEloUser ceu = getEloUserDAO().findByID(Integer.parseInt(uid));
			if (openid.equals("aaaaa")) {
				if (!pass.equals("a111a")) {
					out.print("{\"sign\":{\"value\":-1}}");
					return null;
				}

			} else if (openid.equals("bbbbb")) {
				if (!pass.equals("b222b")) {
					out.print("{\"sign\":{\"value\":-1}}");
					return null;
				}
			} else if (openid.equals("ccccc")) {
				if (!pass.equals("c333c")) {
					out.print("{\"sign\":{\"value\":-1}}");
					return null;
				}
			} else {
				out.print("{\"sign\":{\"value\":-1}}");
				return null;
			}
			CcEloUser ceu = getEloUserDAO().findBySNSID(openid);
			if (ceu != null) {
				CcMap cm = (CcMap) MemCacheUtil.getObject("cm_" + ceu.getId());
				if (cm.getMap().length < 41) {
					cm.initMap2();
				}

				// 当前地图能生成的树总量
				int treemax = (1600 - cm.getTotalUnitSize()) / 50
						- cm.getTotalTreeSize(); 
				// 生成间隔10个小时 
				// int treetime =36000000;
				long treetime = System.currentTimeMillis() - ceu.getLasttree(); 
				// 本次理论数量
				int treecount = (int) (treetime / 3600000L);
				// 更新最后生成时间
				ceu.setLasttree(ceu.getLasttree() + 3600000L); 
				// 数量大于0才开始判断,循环生成
				if (treecount > 0) {
					if (treecount > treemax) {
						treecount = treemax;
					} // 大于3随机加减1-2
					if (treecount > 3) {
						treecount = treecount + (new Random().nextInt(5) - 2);
					} 
					// 循环,先随机出是什么tree,然后随机出x,y.看这个坐标附近的size范围内是否都空
					// 是就放上去,更新totalTreeSize,否则继续循环,N次失败就跳出
					for (int i = 0; i < treecount; i++) {
						Building bu = this.getBuildSettingXML()
								.findRandomTree();
						boolean b = true;
						int count = 0;
						boolean can = true;
						int startx = 0;
						int starty = 0;
						while (b) {
							startx = new Random().nextInt(42);
							starty = new Random().nextInt(42);
							for (int j = 0; j < Integer.parseInt(bu.getSize()); j++) {
								for (int z = 0; z < Integer.parseInt(bu
										.getSize()); z++) {
									int tragetx = startx + j;
									int targety = starty + z;
									if (tragetx > 41 || targety > 41) {
										j = 10;
										z = 10;
										can = false;
										continue;
									} // 等于1表示有东西,0表示空,2表示是边缘,tree可以放,但是不能造建筑
									if (cm.getMap()[tragetx][targety] == null
											|| cm.getMap()[tragetx][targety] == 0
											|| cm.getMap()[tragetx][targety] == 2) { // 放的下

									} else {
										j = 10;
										z = 10;
										can = false;
										continue;
									}
								}
							} // 可以放的下跳出while
							if (can) {
								b = false;
							}
							count++; // 5次随机都放不下,也跳出
							if (count == 5) {
								b = false;
							}
						} // setmap数据
						if (can) {
							for (int j = 0; j < Integer.parseInt(bu.getSize()); j++) {
								for (int z = 0; z < Integer.parseInt(bu
										.getSize()); z++) {
									int tragetx = startx + j;
									int targety = starty + z;
									cm.getMap()[tragetx][targety] = 1;

								}
							} // push tree 列表
							Hashtable<String, List<Tree>> trees = cm.getTrees();
							if (trees == null) {
								trees = new Hashtable<String, List<Tree>>();
							}
							if (trees.get(bu.getType()) == null) {
								trees.put(bu.getType(), new ArrayList<Tree>());
							}
							List<Tree> treeList = trees.get(bu.getType());
							Tree tree = new Tree();
							tree.setX(startx);
							tree.setY(starty);
							treeList.add(tree);
							trees.put(bu.getType(), treeList);
							cm.setTrees(trees);
						}

					}
				}

				MemCacheUtil.setObject("cm_" + cm.getUid().intValue(), cm);
				String token = MD5digest(
						cm.getUid() + "|" + System.currentTimeMillis())
						.substring(8, 24);
				ceu.setLastaction(System.currentTimeMillis());
				ceu.setLastlogin(System.currentTimeMillis());
				getEloUserDAO().saveOrUpdate(ceu);
				System.out.println(System.currentTimeMillis());
				MemCacheUtil.setSession(cm.getUid().intValue(), token);
				String tk = cm.getUid() + "_" + token;
				out.print("{\"token\":\"" + tk + "\"," + cm.toString() + "}");
			} else {
				out.print("{\"sign\":{\"value\":0}}");
			}

			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	public ActionForward login2(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		try {
			String uid = request.getParameter("uid");
			CcMap cm = (CcMap) MemCacheUtil.getObject("cm_" + uid);
			out.print("{" + cm.toString() + "}");

			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 把一系列 act 打包在一起，集中发送的 HTTP 请求
	// 【注意】 只有【无返回值】的 act，才能被打包
	// &map_acts =
	// [{t:1469400255523,b:"LABT|0",a:"move",x:3,y:7},
	// {t:1469400235386,b:"BARK|2",a:"boost_upgrade"},....]
	// 全部service方法都接收2个参数,request和hashtable
	// 单独调用时候传request,打包时候把request中内容打包成hashtable
	public ActionForward map_acts(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			// &map_acts =
			// [{t:1469400255523,b:"LABT|0",a:"move",x:3,y:7},
			// {t:1469400235386,b:"BARK|2",a:"boost_upgrade"},....]
			JSONArray ja = this.getMethodArray(request);
			if (ja != null) {
				for (int i = 0; i < ja.size(); i++) {
					JSONObject jo = (JSONObject) ja.get(i);
					String act = jo.getString("a");
					if (act.equals("build")) {
						int sign = getCocMapService().MapBuild(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("upgrade")) {
						int sign = getCocMapService().MapUpgrade(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("move")) {
						int sign = getCocMapService().MapMove(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("sell")) {
						int sign = getCocMapService().MapSell(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("remove")) {
						int sign = getCocMapService().MapCut(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("collect")) {
						int sign = getCocUserService().Collect(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("train")) {
						int sign = getCocUserService().Tran(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("spell")) {
						int sign = getCocUserService().SpellResearch(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("lab")) {
						int sign = getCocUserService().LabResearch(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("cancel_upgrade")) {
						int sign = getCocMapService().MapCancel(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("cancel_train")) {
						int sign = getCocUserService().CancelTran(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("cancel_spell")) {
						int sign = getCocUserService().CancelSpellResearch(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("boost_upgrade")) {
						int sign = getCocMapService().MapBoost(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("boost_train")) {
						int sign = getCocUserService().TranBoost(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("boost_spell")) {
						int sign = getCocUserService().SpellBoost(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("boost_lab")) {
						int sign = getCocUserService().LabBoost(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					} else if (act.equals("boost_mine")) {
						int sign = getCocUserService().MineBoost(request, jo, sbf);
						if (sign != 1) {
							out.print("{\"error\":{\"value\":\"" + sign+ "\"}}");
							return null;
						}
					}

				}
			}
			out.print("{\"sign\":{\"value\":\"" + 1+ "\"}}");
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 匹配pvp
	public ActionForward pvp_match(ActionMapping mapping,
			ActionForm pcUserForm, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocBattleService().GetEloMatch(request, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 建造
	public ActionForward map_build(ActionMapping mapping,
			ActionForm pcUserForm, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocMapService().MapBuild(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 建造
	public ActionForward map_sell(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocMapService().MapSell(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 升级
	public ActionForward map_upgrade(ActionMapping mapping,
			ActionForm pcUserForm, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocMapService().MapUpgrade(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 取消建造/升级
	public ActionForward map_cancel(ActionMapping mapping,
			ActionForm pcUserForm, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocMapService().MapCancel(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 移动
	public ActionForward map_move(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocMapService().MapMove(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 建造秒杀
	public ActionForward map_boost(ActionMapping mapping,
			ActionForm pcUserForm, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocMapService().MapBoost(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 砍树挖石头
	public ActionForward map_cut(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocMapService().MapCut(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 造兵
	public ActionForward train(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocUserService().Tran(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 造兵秒杀
	public ActionForward train_boost(ActionMapping mapping,
			ActionForm pcUserForm, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocUserService().TranBoost(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 生产/训练速度翻倍 - 矿/新兵训练营
	public ActionForward speed_boost(ActionMapping mapping,
			ActionForm pcUserForm, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocUserService().MineBoost(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 研究所研究
	public ActionForward lab_research(ActionMapping mapping,
			ActionForm pcUserForm, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocUserService().LabGet(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 研究所取消
	public ActionForward lab_cancel(ActionMapping mapping,
			ActionForm pcUserForm, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocUserService().CancelLabResearch(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 研究所收货
	public ActionForward lab_get(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocUserService().LabGet(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 魔法研究
	public ActionForward spell_research(ActionMapping mapping,
			ActionForm pcUserForm, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocUserService().SpellResearch(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	// 收钱
	public ActionForward collect(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocUserService().Collect(request, null, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	public ActionForward friends(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		StringBuffer sbf = new StringBuffer();
		try {
			if (!isLoginV(request)) {
				out.print("{\"error\":{\"type\":\"v\",\"value\":1}}");
				return null;
			}
			if (!isLogin(request)) {
				out.print("{\"error\":{\"value\":1}}");
				return null;
			}
			getCocUserService().getFriendsXML(request, sbf);
			out.println(sbf.toString());
			return null;
		} catch (Exception e) {
			out.print("{\"error\":{\"value\":0}}");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	public ActionForward test(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		try {
			Building trs = getBuildSettingXML().findBuByID("QUEN");
			System.out.println(trs);

			return null;
		} catch (Exception e) {
			out.print("更新失败!");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}

	public ActionForward test2(ActionMapping mapping, ActionForm pcUserForm,
			HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		try {
			CcMap cm = (CcMap) MemCacheUtil.getObject("cm_"
					+ request.getParameter("uid"));
			System.out.println(cm.getWalls().size());
			MemCacheUtil.delValue("cm_" + request.getParameter("uid"));
			return null;
		} catch (Exception e) {
			out.print("更新失败!");
			out.flush();
			out.close();
			e.printStackTrace();
		}
		return null;
	}
	*/
}